from tortoise.models import Model
from tortoise import fields


class DouyinComment(Model):
    id = fields.IntField(pk=True)
    comment_text = fields.TextField(description="评论内容")
    comment_time = fields.DatetimeField(description="评论时间")
    user_id = fields.CharField(max_length=32, description="用户ID")
    user_nickname = fields.CharField(max_length=32, description="用户昵称")
    user_sex = fields.CharField(max_length=8, description="用户性别")
    sub_comment_count = fields.IntField(default=0, description="子评论数")
    likes = fields.IntField(default=0, description="点赞数")
    address = fields.CharField(max_length=32, description="IP属地")
    emotional_value = fields.FloatField(default=0.5, description="情绪值")

    # 多对一的关系，评论属于某个视频
    video = fields.ForeignKeyField("models.DouyinVideo", related_name="douyin_comments")


class DouyinVideo(Model):
    aweme_id = fields.CharField(max_length=32, description="视频ID", pk=True)
    title = fields.CharField(max_length=255, description="视频标题")
    owner = fields.CharField(max_length=32, description="视频作者")
    likes = fields.IntField(default=0, description="点赞数")
    comments_count = fields.IntField(default=0, description="评论数")

    # 多对一的关系，视频属于某个用户
    user = fields.ForeignKeyField("models.User", related_name="douyin_video")
